package org.wuqi.microdataservice.service;

import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wuqi.api.model.BaseInfo;
import org.wuqi.api.service.PlatBaseInfo;
import org.wuqi.microdataservice.mapper.BidInfoMapper;
import org.wuqi.microdataservice.mapper.LoanInfoMapper;
import org.wuqi.microdataservice.mapper.UserMapper;

import java.math.BigDecimal;


@DubboService(interfaceClass = PlatBaseInfo.class,version = "1")
@Service
public class PlatBaseInfoServiceImpl implements PlatBaseInfo {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private BidInfoMapper bidInfoMapper;
    @Autowired
    private LoanInfoMapper loanInfoMapper;
    @Override
    public BaseInfo queryPlatBaseInfo() {
//        统计总人数
        int userNum = userMapper.selectCountUser();
//        统计利率
        BigDecimal bigDecimal = loanInfoMapper.selectProductAvg();
//        总金额
        BigDecimal bigDecimal1 = bidInfoMapper.selectSumMoney();
        BaseInfo baseInfo = new BaseInfo(bigDecimal1, bigDecimal, userNum);
        return baseInfo;
    }
}
